Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

356
Visualizações
Why [object Object] mentions "object" twice?

[object Object] is the default string representation of a JavaScript Object.

I would understand if it was just [Object] or [object], but why [object Object]? Why the first word is lowercase and the second one is uppercase? Is it part of JSON or JavaScript?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

All objects have a toString method that displays something in the format [object type], where type is the object type.

When called on null you get [object Null] and when called on an object you get the string [object Object] because it's based on the Object constructor (capital "O"), that's why it says object twice, it's an object of the type Object.

MDN

JSON is a lightweight data-interchange format, and doesn't really have anything to do with JavaScript other than being named "JavaScript Object Notation" because it's written like a JavaScript object.

over 4 years ago · Santiago Trujillo Relatório

0

I would understand if it was just [Object] or [object], but why [object Object]?

Because it is an object created from the basic Object class.

From the spec:

Return the String value that is the result of concatenating the three Strings "[object ", class, and "]".


Is it part of JSON or JavaScript?

It has absolutely nothing to do with JSON.

over 4 years ago · Santiago Trujillo Relatório

0

The first object denotes that the type of the thing being logged is an object. It's also hard-coded in the language specification here.

The second Object denotes the constructor property, for example:

Object.prototype.toString.call(""); // [object String]

The algorithm just says: "Get the [[class]] property of the object and then return '[object ' + class + ']'.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda